package com.ccp.dev.workflow.service.bpm.impl;

import com.ccp.dev.core.basic.bpm.util.FlowableUtil;
import com.ccp.dev.workflow.service.bpm.IBpmFlowableService;
import com.ccp.dev.workflow.service.bpm.cmd.AllowBackCallActivityCmd;
import com.ccp.dev.workflow.service.bpm.cmd.CallActivityRejectCmd;
import com.ccp.dev.workflow.service.bpm.cmd.TaskAllowRejectCmd;
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
import org.springframework.stereotype.Service;

/**
 * ClassDescribe:
 *
 * @author :jiayueqiao
 * Date: 2019-10-28
 * Since:1
 */
@Service
public class BpmFlowableService implements IBpmFlowableService {
    @Override
    public boolean isTaskAllowBack(String taskId) {
        CommandExecutor commandExecutor=FlowableUtil.getCommandExecutor();
        TaskAllowRejectCmd cmd=new TaskAllowRejectCmd(taskId);
        return commandExecutor.execute(cmd);
    }

    @Override
    public boolean allowCallActivityBack(String taskId) {
        CommandExecutor commandExecutor = FlowableUtil.getCommandExecutor();
        AllowBackCallActivityCmd cmd = new AllowBackCallActivityCmd(taskId);
        return commandExecutor.execute(cmd);
    }

    @Override
    public boolean reject(String taskId, String nodeId) {
        CommandExecutor commandExecutor = FlowableUtil.getCommandExecutor();
        CallActivityRejectCmd cmd = new CallActivityRejectCmd(taskId);
        cmd.setTargetNode(nodeId);
        return commandExecutor.execute(cmd);
    }
}
